package queue

//使用别名方式拓展

//An FIFO queue.
type Queue []int

//Pushes the element into the queue.
//  e.g. q.Push(123)
func (q *Queue) Push(v int) {
	*q = append(*q, v)
}

//Pops element from head.
func (q *Queue) PopLeft() int {
	head := (*q)[0]
	*q = (*q)[1:]
	return head
}

//Pops element from tail
func (q *Queue) Pop() int {
	tail := (*q)[len(*q)-1]
	*q = (*q)[:len(*q)-1]
	return tail
}

//Returns if the queue is empty or not.
func (q *Queue) IsEmpty() bool {
	return len(*q) == 0
}
